﻿<cfsilent>
	<cfscript>
	
		
		sql = "SELECT  a.sch_id,
					   a.sch_name,
					   a.sch_name_eng,
					   a.sch_establish,
					   a.sch_citycode,
					   a.sch_address,
					   a.sch_zipcode,
					   a.sch_host,
					   a.sch_type,
					   a.sch_prop 
				FROM t_school a ";
		queryObj = new Query( datasource=application.dnsSlave) ;
		rs_school= queryObj.execute( sql=sql ).getResult();
		
		event.setArg("pageTitle", "教学运行基础数据 - 学校信息更新 - " & rs_school.sch_name);

		sql = "SELECT  a.sch_host,
						   a.sch_host_name
					FROM t_school_hoster a 
					ORDER BY a.sch_host ASC";
		queryObj = new Query( datasource=application.dnsSlave) ;
		rs_hoster= queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT  a.sch_type,
					   a.sch_type_name 
				FROM t_school_type a  
				ORDER BY a.sch_type ASC";
		queryObj = new Query( datasource=application.dnsSlave) ;
		rs_type= queryObj.execute( sql=sql ).getResult();
		
		sql = "SELECT  a.sch_prop,
					   a.sch_prop_name
				FROM t_school_prop a  
				ORDER BY a.sch_prop ASC";
		queryObj = new Query( datasource=application.dnsSlave) ;
		rs_prop= queryObj.execute( sql=sql ).getResult();
	
		sql = "SELECT  a.area_code,
					   a.area_name
				FROM t_dict_china_area a 
				ORDER BY a.area_code ASC";
		queryObj = new Query( datasource=application.dnsSlave) ;
		rs_area= queryObj.execute( sql=sql ).getResult();

		targetArgs = structNew();

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('organizeAdministration')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">二级学院行政建制</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>更新学校基础信息
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="schoolInfo">
		<li>
			<div class="clearfix" id="modify">
				<div class="UItab">
					<div class="tabLables">
						<span class="active" id="labSchoolBaseInfo" tabTarget="schoolBaseInfo">学校信息</span>
						<span id="labFindSchool" tabTarget="findSchool">查找学校信息</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					function showFinder() {
						
						$("div.tabLables > span").removeClass("active");
						$("div.tabContent").hide();
						
						$("span#labFindSchool").addClass("active");
						$("div.tabContent#findSchool").show()
						
						return void(0);
					}
					
					function showForm() {
						
						$("div.tabLables > span").removeClass("active");
						$("div.tabContent").hide();
						
						$("span#labSchoolBaseInfo").addClass("active");
						$("div.tabContent#schoolBaseInfo").show()
						
						return void(0);
					}
					
					// -->
					//]]>				
				</script>
				
				<div id="findSchool" class="tabContent">
					
					<form id="formSearch" class="formWrapper Transparent" method="post">
						<div class="label">
							<b>学校名称或代码</b>
							<input name="Keywords" id="Keywords" type="text" class="typeText" verification="required" maxlength="128" value="<cfoutput>#event.getArg('Keywords')#</cfoutput>" />
						</div>
						<hr/>
						<div class="lable">
							<input class="button1" type="submit" value="搜索学校标准信息" />
						</div>
					</form>
					
					<div id="formSearchResult" class="UICardTable">
					</div>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						$("#formSearch").submit(function(){
							
							if (processVerfiyForm('formSearch')) {
								
								$.getJSON(
									'<cfoutput>#buildURL("getSchoolByKeywords")#</cfoutput>',
									{
										'Keywords': $("form#formSearch input#Keywords").val(),
										'seed': (new Date()).getTime()
									},
									function(data) {
										
										$div = $("div#formSearchResult").html("");
																				
										for (var i=0; i<data.length; i++) {
											
											var $element = $("<dl><dt><em class='campus'></em><dd><h3>" + data[i][1] + "</h3><p>(" + data[i][0] + ")</p></dd></dt></dl>");
											
											$element
												.addClass("clickAble")
												.attr({
													'SchoolID' : data[i][1],
													'SchoolName' : data[i][0]
												})
												.click(function(){
													
													var name = $(this).attr('SchoolName');
													var id = $(this).attr('SchoolID');
													
													$("form#formCreate input#SchoolID").val(name);
													$("form#formCreate input#SchoolName").val(id);
													
													showForm();
												})
												.appendTo($div);
											
										}
									});
								
							}
							
							return false;
						});
						// -->
						//]]>				
					</script>
					
				</div>
				
				<div id="schoolBaseInfo" class="tabContent">
					<form id="formCreate" onSubmit="javascript:return processVerfiyForm('formCreate');" class="formWrapper" method="post" action="<cfoutput>#buildURL('schoolUpdateDo')#</cfoutput>">
						
						<div class="label">
							<span class="req">*</span><b>学校代码</b>
							<input name="SchoolID" id="SchoolID" type="text" class="typeCode" verification="required" maxlength="5" value="<cfoutput>#event.getArg('SchoolID', rs_school.sch_id)#</cfoutput>" />
							<p class="notice">
								注意: 学校代码应该使用教育部颁布给当前学校的唯一代码, 参考标准《JB/GDXXHKYJG-2006 高等学校和科研机构代码》, 该代码适用于所有提交于教育部的信息的数据交换, 一旦填写则不可更改。
								<br/>
								如果您不确定学校的代码, <a href="javascript:showFinder();">请从这里进行查找</a>
							</p>
						</div>
						
						<hr/>
						
						<div class="label">
							<span class="req">*</span><b>学校正式名称</b>
							<input name="SchoolName" id="SchoolName" type="text" class="typeTextShort" verification="required" maxlength="30" value="<cfoutput>#event.getArg('SchoolName', rs_school.sch_name)#</cfoutput>" />
						</div>
						<div class="label">
							<b>英文名称</b>
							<input name="SchoolEnglishName" id="SchoolEnglishName" type="text" class="typeText typeEnglish" maxlength="180" value="<cfoutput>#event.getArg('SchoolEnglishName', rs_school.sch_name_eng)#</cfoutput>" />
						</div>
						<div class="label">
							<b>建校时间</b>
							<cfset targetYear = left(rs_school.sch_establish, 4) />
							<select name="forYear" class="inlinePart">
								<cfloop from="#year(now())#" to="#(year(now())-200)#" index="_year" step="-1">
									<option <cfif _year eq event.getArg("forYear", targetYear)>selected="selected"</cfif> value="<cfoutput>#_year#</cfoutput>"><cfoutput>#_year#</cfoutput></option>
								</cfloop>
							</select>年
							<cfset targetMonth = right(rs_school.sch_establish, 2) />
							<select name="forMonth" class="inlinePart">
								<cfloop from="1" to="12" index="_month">
									<option <cfif _month eq event.getArg("forMonth", targetMonth)>selected="selected"</cfif> value="<cfoutput>#numberFormat(_month, '0_')#</cfoutput>"><cfoutput>#_month#</cfoutput></option>
								</cfloop>
							</select>月
						</div>
						<hr/>
						
						<div class="label">
							<b>行政区域</b>
							<select name="forProvince" id="forProvince" class="inlinePart"></select>
							<select name="forCity" id="forCity" class="inlinePart"></select>
							<select name="forCounty" id="forCounty" class="inlinePart"></select>
							
							<cfset i = 0 />
							<cfset targetProvince = left(rs_school.sch_citycode,2) />
							<cfset targetCity = left(rs_school.sch_citycode,4) />
							<cfset targetCounty = rs_school.sch_citycode />
							
							<script language="javascript" type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function() {

									var cityArray = [
										<cfloop query = "rs_area" >
											<cfset i++ />
											<cfset id = rs_area.area_code />
											<cfset pid = "" />
											<cfif right(id, 4) eq "0000">
												<cfset id = left(rs_area.area_code, 2) />
											<cfelseif right(id, 2) eq "00">
												<cfset id = left(rs_area.area_code, 4) />
												<cfset pid = left(rs_area.area_code, 2) />
											<cfelse>
												<cfset pid = left(rs_area.area_code, 4) />
											</cfif>
											['<cfoutput>#id#</cfoutput>','<cfoutput>#rs_area.area_name#</cfoutput>','<cfoutput>#pid#</cfoutput>']<cfif i lt rs_area.recordCount>,</cfif>
										</cfloop>
										];
								
									function inputFlush(inputID, dataArray, parentID, preValue) {
									
										$("#" + inputID).removeOption(/./);
										for (var i = 0; i < dataArray.length; i++) {
											if (cityArray[i][2] == parentID) {
												$("#" + inputID).addOption(dataArray[i][0], dataArray[i][1]);
											}
										}
										
										if (preValue) {
											$("#" + inputID).val(preValue);
										}
										else {
											$("#" + inputID).val($("#" + inputID + " option:first").attr('value'));
										}
										
										
									}
									
									/* Preset value */
									inputFlush("forProvince", cityArray, "", '<cfoutput>#event.getArg("forProvince", targetProvince)#</cfoutput>');
									inputFlush("forCity", cityArray, $("#forProvince").val(), '<cfoutput>#event.getArg("forCity", targetCity)#</cfoutput>');
									inputFlush("forCounty", cityArray, $("#forCity").val(), '<cfoutput>#event.getArg("forCounty", targetCounty)#</cfoutput>');
									
									$("#forProvince").change(function(){
										inputFlush("forCity", cityArray, $(this).val());
										inputFlush("forCounty", cityArray, $("#forCity").val());
									});
									
									$("#forCity").change(function(){
										inputFlush("forCounty", cityArray, $(this).val());
									});
									
									
									
									
								});
								// -->
								//]]>				
							</script>
							

						</div>
						<div class="label">
							<b>街道地址</b>
							<input name="SchoolAddress" id="SchoolAddress" type="text" class="typeText" maxlength="30" value="<cfoutput>#event.getArg('SchoolAddress', rs_school.sch_address)#</cfoutput>" />
						</div>
						<div class="label">
							<b>邮编</b>
							<input name="SchoolZipCode" id="SchoolZipCode" type="text" class="typeCode" maxlength="6" value="<cfoutput>#event.getArg('SchoolZipCode', rs_school.sch_zipcode)#</cfoutput>" />
						</div>
						<hr/>

						<div class="label">
							<b>举办者</b>
							<select name="HostCode" id="HostCode">
                                <cfloop query="rs_hoster" >
								<option <cfif rs_hoster.sch_host eq event.getArg("HostCode", rs_school.sch_host)>selected="selected"</cfif> value="<cfoutput>#rs_hoster.sch_host#</cfoutput>"><cfoutput>#rs_hoster.sch_host_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						<div class="label">
							<b>办学类型</b>
							<select name="TypeCode" id="TypeCode">
                                <cfloop query="rs_type"  >
								<option <cfif rs_type.sch_type eq event.getArg("TypeCode", rs_school.sch_type)>selected="selected"</cfif> value="<cfoutput>#rs_type.sch_type#</cfoutput>"><cfoutput>#rs_type.sch_type_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						<div class="label">
							<b>学校性质</b>
							<select name="PropCode" id="PropCode">
                                <cfloop query="rs_prop" >
								<option <cfif rs_prop.sch_prop eq event.getArg("PropCode", rs_school.sch_prop)>selected="selected"</cfif> value="<cfoutput>#rs_prop.sch_prop#</cfoutput>"><cfoutput>#rs_prop.sch_prop_name#</cfoutput></option>
								</cfloop>
							</select>
						</div>
						<hr/>
						
						<div class="lable">
							<input class="button" type="submit" value="提交" />
							<input class="button" type="reset" value="重设表格" />
						</div>
					</form>
				</div>
			</div>
		</li>
	</ul>
</div>		